package com.freemypay.java.十三字符串.二重载和StringBuilder;

import java.util.Random;

/**
 * StringBuilder
 * 					是否线程安全		应用			
 * StringBuffer			是		非线程安全和线程安全
 * StringBuilder		否		线程安全（非公共资源，方法内部）
 * 总结：在线程安全的情况下，StringBuilder比StringBuffer效率高。
 * @author yesixian
 * @date 2018年8月2日
 */
public class UsingStringBuilder {
	public static Random rand = new Random();
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		StringBuilder result = new StringBuilder("[");
		for (int i = 0; i < 25; i++) {
			result.append(rand.nextInt(100));
			result.append(",");
		}
		result.delete(result.length() - 2, result.length());
		result.append("]");
		return result.toString();
	}
	
	public static void main(String[] args) {
		UsingStringBuilder usb = new UsingStringBuilder();
		System.out.println(usb.toString());
	}
}
